/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.system.source.model;

import com.system.source.data.DetailPeminjaman;
import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Pinds
 */
public class detailPeminjamanTabelModel extends AbstractTableModel {

    private List<DetailPeminjaman> isi = new ArrayList<DetailPeminjaman>();

    public void tambahJenisFilm(DetailPeminjaman jf) {
        isi.add(jf);
        fireTableRowsInserted(getRowCount(), getColumnCount());
    }

    public void hapusTabel(int i, int row) {
        isi.remove(i);
        fireTableRowsDeleted(i, row);
    }

    public DetailPeminjaman getJenisFilm(int index) {
        return (DetailPeminjaman) isi.get(index);
    }

    @Override
    public int getRowCount() {
        return isi.size();
    }

    @Override
    public int getColumnCount() {
        return 3;
    }

    @Override
    public String getColumnName(int column) {
        switch (column) {
            case 0:
                return "Kode DVD";
            case 1:
                return "Judul Film";
            case 2:
                return "Harga";
            default:
                return null;
        }
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        switch (columnIndex) {
            case 0:
                return isi.get(rowIndex).getKodeDVD();
            case 1:
                return isi.get(rowIndex).getJudulFilm();
            case 2:
                return isi.get(rowIndex).getHarga();
            default:
                return null;
        }
    }
}
